Tidy up unsued code and templates