more adjustments to csv output
rewrite of csv output and bugfixing