Handling malformed data and unicodes