Fixing wrong compilation context in create_instance optimizer