Properly handle spaces in paths, close #1777