[REFACTOR] Replaced content-type conditionals with lookup function.
[REFACTOR] Replaced chunked output with pipes, simplifying code.