Fix up lookup code to deal with spaces etc. in directory names