Refactored URL handling.