feat: refactor to use function options

Major refactor to use function options, which is not backwards
compatible with v1.
23 files changed