Add URL validation and fix bugs