* Changed type of loop variable
* Cleaning and minor optimisations