Added some more formal comments throughout.