log error checking and message cleanup