Some work on space distribution

(may not compile, this is an intermediary commit)