refactored metrics

@rcrichton please review, this is a new branch based on a more recent version of master
Just some minor white space issues here.