Almost done refactoring
Done refactoring