Fix a bug in path cleaning