Separate optimization from statistic redux

This is a rebased version of #1914.  I decided to go ahead and make a new PR so that it can easily be run through Travis and the like.  Otherwise no major differences.  Once the CI gives us a green checkmark this should be merged instead of #1914.
Ack. I thought I saw that in the logs too but I couldn't find where it was coming from.  Incidentally, I removed this already but in a different branch (the one where I'm refactoring) =_=