big refacto for shutdown and command lines