Style refactoring and commenting