Improve the documentation of the arguments and return value of each function.  Also fix typos.