Added cleanup and checkTypes methods

I was checking types so often that I moved it to it's own method.  Added a cleanup method, which still has many errors.