Made path cleaning simpler and removed underscore dependency.