Refactor now instead of later.

I had been planning on doing this for some time, why not do it now?
Miscellaneous changes.