Add space with entity creation/deletion

This is a first attempt with space structure, this commit also include a
lot of code refactoring