Fix PianoRoll changing editMode outside window

If an user Ctrl+Clicked on a track, e.g. copying/muting it, but the
focus was still on the PianoRoll window the mode would change

Fix #1501
Make command line project export working again
Fix some memory access issues
Merge pull request #1503 from badosu/master

Fix PianoRoll changing editMode outside window
Merge pull request #1513 from DanWin/cmd

Make command line project export working again