[#239] Code clean up

* Use final variables
* Don't overwrite the value of the parameter `cursor`
* Formatting