Code tidied