Router implementation (first part)