Fixed safe mode problem
Misc fixes