Initial work, began refactoring