Documents some of the source code, cleaning it up in the process.