Heavy refactoring pt.2
Heavy refactoring pt.3