Merge "Improve handling of invalid frames."

Change-Id: Icef5226a70260607c190126c1c0cc28b796e759c