Fix throttling code to work properly with event loop.