reimplement node cloning by passing a cache object around. much simpler and actually works