Hey it me again, I had some free time so I merged your pull request and also addressed those issues myself and added some improvements.
Just let you know so you don't have to work on those problems anymore. But feel free to improve it even more if you can, help is always appreciated.
I thank you and also give you the credit in the mod portal.
Cheers,