Brought up to modern coding standard and indentation.