Did some refactoring, merged some unecessary code