Fix writer flush and importing missing keys

WriteQueues weren't emptying their queue after writing... shit. There
was also a case of reaching into a subdoc when a key does not exist.
Not sure how this didn't come up before.