Fixes #339, and refs #349 as it may also resolve it.
Merge pull request #350 from couchbase/issue-339

Fixes #339