Replace avl code with a simple (but inefficient) temporary storage mechanism for events, to test if the avl code was causing the random memory corruption.