fixed #29, and various bugs related to routing