Fixed a regression in safeEncode