Thanks for the suggestions!
It’s always nice to clean up the code a bit. 
Regarding the last correction, I think the cast was necessary in an older version despite the typo.
I was referring to this post 308. Good to know it’s apparently not needed anymore.