Duplicate json structures before cleaning them.

When calling Util.clean_json there was a rather nasty side-effect that it
changed the original structure in some cases. Duplicate before cleaning to
prevent this.