More code tidyup