fixed a couple of bugs at restarting