Better error handling, improved documentation.
Clean up some old code, better comments, better error handling.