Massive refactoring and development of the factory classes. Does not compile.