update the keys, handle types intelligently