Simplified stream corruption detection logic.

In other words we have one copy-paste less. Also changed the error message to something more understandable.