Improved the main router to support regex.