Refactoring into stateless routers