Rewrite code invoker to make it working with primitives properly