fixed restore bugs and added use_sudo option