[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?
I don't really understand what this means. @arbitbet can you explain it a bit?