Started refactoring/cleanup.