Make command line project export working again

This fixes two segfaults, that were happening immediately when trying to export a project from command line.
A also fixed some memory access issues I noticed during export.