improve router class, inject dependencies and globals