Minor bugfixes to router, main etc.