Fixed build and added some message handling logic in the main task