improved implementation of Metrics, is now much more memory efficient and faster