Tidied up codes.