Add special cases to avoid the effects of bugs

There is a number of problems. I need to fix it in the metric code
itself. For now I have added some special cases to deal with these.

Signed-off-by: Konrad Reiche <konrad.reiche@gmail.com>