Rework the RESTful stuff, and fix some bugs