based on the branch 0.6.x of rcouch