Added code to deal with truncated messages.