Remove unused variables

I've been playing with phpmd and found some unused variables. Sharing here in case you think this is useful. I'm not sure if it is a good idea or not to merge this. It might break thinks where there is poor test coverage.