A lot. See description!

Added exhaustive documentation of the major functions.
Removed some dead code.
Include string.h for compatibility with other hosts.
Added some basic exception handling around lines that are known to
possibly throw an exception, given a bad input.