more nitpicking and refactoring