Huge refactoring, beginning to write sorting methods