bug fixes in routing and sql