Replace all instances of GLib.main_loop usage with using the C new function