   # ... and that would slow it down a bit.)
   @writeOp = (docName, opData, callback) ->
     # ****** NOT SAFE FOR MULTIPLE PROCESSES. Rewrite me using transactions or something.
-    checkIndex ->
+    checkIndex (err) ->
+      return callback? err if err
       client.collection 'ops', (err, collection) ->
         return callback? err if err
       

      
  # Data = {v, snapshot, type}. Error if the document doesn't exist.
  @getSnapshot = (docName, callback) ->
    checkIndex ->
      client.collection 'docs', (err, collection) ->
        return callback? err if err
      

  # end can be null. If so, returns all documents from start onwards.
  # Each document returned is in the form {op:o, meta:m, v:version}.
  @getOps = (docName, start, end, callback) ->
    checkIndex (err) ->
      return callback? err if err
      if start == end
        callback null, []
        return
