This is a lot like (identical to maybe?) what we did for source spaces, can also be refactored.