Added -p flag to mkdir and fixed patch for Mac OS ('rejecting file name with
".."')