general tidy of code