Security patch, nonces and escaping added