Reduce the amount of global calls.

 * Also, due to reducing the number of global
   calls, I found 2 small bugs that I then
   fixed.