Stole an actual query string parser to get this bloody thing to work properly, finally.