Tidied up the code.