Tidy of code and amendments