Some small refactorings, comments added