Code formatting is unified and some comments are added.