This diff is pretty confusing b/c I moved one function outside of it's wrapper function. It's a lot easier to see what's going on by just looking at the file itself.