Refactor router and server