Minor cleanup and refactorings