More bugfixes for report generation
Many small bugfixes/improvements
Merge with master