Opt globals

This branch aims to optimise many uses of globals in PHP.