Rewrite the frontend a little bit to accomodate different event loops