Refactoring. Mostly comments and formatting