Global minor refactoring and comments