Divide router.c into logical pieces