Deal with spaces in file references

Fixes gh-1169