Added saftey features to prevent buttons from being pressed at the wrong times.