Some better error handling for invalid messages (issue #31)