Have done a little refactoring thanks to ReSharper to clean the code.