Complete rewrite for 2.0.  See the changelog for more details.