Added checks for spaces in paths to handle them appropriately.