Tried to improve restart function.