Added a delay in the main loop, also error handling if there is no message.