adds core routing, ported from aaronparecki.com