Check for space existence before refering to its properties

From #3325.