Fix bugs of edit loop and restore backup