expand comments and basic refactoring