Introduce router, move platform to routes

and minor code simplifications