Add some code documentation and fix a few typos.