Improved url handling