Did some refactoring/cleanup.