fixed collision and segfault on event + lots of little fix