Minor cleanups and refactorings