CouchDB sync issues

After merging in your latest changes to master, I ran into some cast exceptions during syncing to CouchDB.