Refactor router to not be stupid