Re-writing the URL parsing to be less spaghetti
Rebuilt url parser for robustness and clarity.

The url parser is now much smaller and much clearer (less spaghetti). Also, update to the latest htmlparser version