add debug toggle, change save_dir to root_path