Fixed small bugs.  Still needs testing.