Started extensive refactoring