Fixed program flow from router to buildResponse.

Improved some variable names. Fixed jpeg/jpg pattern match in
contentType.