Reorganize the CouchDB code a little. Dunno if I like it any better. (Still haven't dealt with the views, either. Argh.)