Begun coding cleanup and refactoring