Router code cleanup