Remove cruft. Make url handling more robust