Data I pass to the delete_event (or other event) handler gets corrupted.

All event handlers take an additional argument which contains information about the event that triggered the handler. So, a delete_event handler must be declared as:

gint delete_event_handler (GtkWidget   *widget,
                           GdkEventAny *event,
                           gpointer     data);