Fixing bug introduced by issue 542 where some results are not included and duplicate objects are returned instead.