Tidied some of the code.