Add better error handling on malformed data.