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.
This gives a sphinx warning and makes the travis-ci build fail:
https://travis-ci.org/astropy/astropy/jobs/26970976#L3333