fix bad couch query
Merge pull request #507 from dimagi/cz

fix bad couch query (Case:64202)
fix bug in trimdata
Merge pull request #508 from dimagi/ugh-fix

fix bug in trimdata