Fix crash

This change fixes the crash in the simulator. I'm not even sure if that is a bug or not, because maybe "self" shouldn't be there in a different thread. But retaining the reference in a dummy variable fixes the crash.