Add some mainloop instrumentation