Replace old metrics with new metrics.

* Remove unused code from old metrics.
* Change templates to handle new metrics.
* Minor compatibility fixes between old and new metrics.
* Add factory for new metrics