Replaced db with ndb. Closes #46.