#428 : merge branch 3.11/428 bdsi exporter fixes
Various fixes/improvements requested by GFI, see the TODOs in #428 (closed) for the details. Also made a small refactoring regarding serialization of INSERT statements to avoid a ton of string copies.