general tidy of code and docs