fix #102, and cleanup/improve the gtk_main handling considerably