Code style cleanup

Ran a couple inspections on the code and fixed a couple obvious code style issues that were fairly easy to fix. PhpStorm found some more unused variables and other minor things, you want me to hunt those down as well, @mikejolley?