Properly clone objects when applying filters to them. Fixes gh-337