Fixed program flow from router to buildResponse.

Moved smaller classes to the top for readability. Fixed some variable
names.