fixed some crashes and memory leaks, that prevented switching demos.