Minor clean-up and refactoring