bugfixes and improovements for export