Fixed a problem in the factory to use proper inheritance.