Began refactoring
Mostly finished refactoring