Fixed bug in factory.