Small cleanup and refactoring