Fixed some bugs regarding restart