More comments and small refactoring