Improved stream reading, JSON try-parse, and contentType check.