move to couchdb and fix some issues