Minor refactorings and cleanups based on code review