Fixed bugs in newly committed code
Tidy up