reordering a little to do more work while waiting for SPI
cleaning up code
make code more stable. Things seem to work better if handle_events is only called in the program loop