added a toString
implementing more of the API, cleaning up error checking