Code tidyups