removes a minor inefficiency
kills unchecked warnings
Ensures that routers return only valid states.