CODE: Some safety modifications and refinements,