Convert global variables to const

This results in a 30% speedup