added some more event handler flags and checked for mem validity