Refactoring. Mostly adding comments.