Pulled separate database code into distinct modules.
Use consistent error handling for all couch DB requests, using proper error codes.