Some minor cleaning up and refactoring.