Cleaned up Metrics and added custom metrics.

Cleaned up the metrics handling and added custom metrics with some help
from @JabJabJab.