[WIP] Import export fixes

This is not completely finished. I have to review some more paragraphs. But you can please have a look at the parts that have been reviewed yet.

ping @arbitbet What do you think?