Final code tidy-up