X27 stepper motor

I have a code like this, I partially changed it to km/h by changing it from mph, but I encountered 2 problems. Firstly, it reaches the position in the form of a pause when turning the clock, it advances to the desired position without tasting what I want. Secondly, when the power is suddenly cut off, even if I set the final position to 0 degrees, it occurs in a sudden power cut. When I re-feed or reset, it continues from a position other than the current one, in short, it starts outside the current route. What changes can I make about these two problems? Thank you.