Some code tidying

Removed dependencies on function passing data and instead put the
information on the request and response objects