Minor style changes and some refactoring.