[WIP] Ranking metrics

An early PR to make reading the diff easier. Not ready for detailed comments but high-level comments welcome :)