Add urlencode to the compat module
Use the compat urlencode in utils
Fix python3 compatibility
Use namespaced session keys to avoid clashes, and pop after use