Fix minor bugs in restart logic