Tidyup of code