Beginning cleanup and refactoring.