Fixing whitespace, content_type as str and handling errors properly