Fix potential NPE with no cached messages.