Fix minor bugs in export implementation

Why isn't this merged?