Lightened the code.

Tidied up and optimised a little bit.