Avoid race conditions for valid/invalid messages