cleanup: reduced scope and moved constants to .cc file

I admit I have problems doing small PRs but I am going to try and do smaller PRs so it's easier to see what's happening. Starting off with a smaller clean up. Gonna attack function parameters next (constant references) and after that break out a couple of functions. Just so you know what's in my pipe (today at least).