more careful handling of spaces, fixes #42