Code tidy

Tidied code and changed coding style to be less compact and more readable.