Fix overflow in sdb_set and correct autosync on delete