Tidy up code and bring into line with style guidelines and correct gender field
Improvements to code