Replace event loop with pub/sub