Add warning when adding duplicate keys, fix an error.