Fix some bugs duplicate keys