Added improved debugging for incorrect message handling.