Fix sanitize

Some refactoring and adding sanitization for urls.