Finished some minor refactoring, finished bulk of major functionality