Fixed some issues regarding dirnames with spaces in them