Started refactoring, want to clean up some more logic slightly