improved 'route' stuff, fixed some memory handling