Minor refactorings and comment fixes