Fix recursion problem in _clone function, fixes #239