feat: refactor to use function options Major refactor to use function options, which is not backwards compatible with v1.