Distinguish between malformed and invalid deserialization errors

1st draft for fixing #820