Refactored factory creation to work properly and be declared in the correct class.