Replaced loops for button presses with GPIO interrupt events. Needs testing though.