Fixing the order of the spaces context methods and minor coding fixes.