Make URL handling a bit easier for the future
Add much more error handling and debugging.