Better error and message handling