Fix settings cannot set or add keys with more than one dot

For instance, adding a key-value paire which the key is "a.b" can be
successful, while adding the key "a.b.c.d" will fail. This patch fixes
this issue.