Some minor refactoring, commenting