LOTS of code tidy