Tidied up and removed dead code.