critical safety valve fixes in internal commands and some minor fixes