add couch1.5 compatible code

Please don't merge. This still need further test.