Fixed some bugs.  Added cleanup