Stop x being global
Another little tidy up