Better error handling.
Added visual feedback for sleep.
Added sleep and reordered code to deal with running app.