More refactoring, code style, comments.