Added code to handle going to sleep and responding to button to wake up