Fixed errors with serializing objects to JSON

And I cleared up some of the logic behind saving things to the database. Now
the app routes the request to the proper DB.