Fixed memory allocation issues

This should hopefully fix the route bugs…