Tidy code and documentation