refactor the request.js file

Here's some initial work on refactoring the request.js file.
I added some helper functions, and organized other helper functions.
Also cleaned up Request constructor a bit.

Work in progress, feedback would be awesome :)