Optimisation by MarioG1

Needs to be cleaned - tabs are spaces, stray files, indenting etc.

Double check programming.

Thanks Mario.