Add a load of comments, and bring code into compliance with Dolphin style.