Fix of several bugs and finished metric implementation

There has been several fixes done by me (Martin Baar alias secondaryObject) and Dmitri Makarov alias dmakarov which would be nice to have released. Also functionality to see custom metrics in the reports has been finished.