fix crash in BasicDemo and some other minor things (see commits)