canonicalize keys as much as possible