FactoryWrapper cast optimization