more improvements and make CSV generation work