More cleanup and refactoring...