Minor cleanup and refactor