Avoid KeyError and double-escape