Parses the request into a map. Will take time to fix up comments and neatness.