fix memory problems as reported at #3620
fix for path_hash not unique as reported at #3641