Tidied up a bit of the code.