Small changes for clang compatibility
I have made some minor changes (mostly to space.c) so that the code now compiles out of the box with the clang compiler.
The main change is the removal of nested functions in space.c. They have been replaced by static functions.