Some more fixes

I think this is final now. I've done some testing with import/export and it looks good. (There's a bug in Zotero with character encoding. I'm submitting a patch for that)

After this, I think the whole thing is OK to be squashed and merged.