adding uri_max_length and some code cleanup