fixing autoload issues and introducing factory