clean up code, add some more error checking, comments