Tidied up code a little.