Simple routing and some code optimization