Did some minor cleanup and refactoring.