started refactoring with factories, and more modularization

factories in factories folder