Added error handling for malformed URLs. should fix #7