Upgrading to ndb and cleaning up some more code.