While reviewing danpb's win32 patch for the mainloop integration code, I found 2 more issues in the existing code (one leak, one bug). These patches fix this (first patch is just some cleanup). Christophe