Lots more cleanup and bug fixes.  Some comments out-of-date.