minor cleanup and refactor