Update setdefault to ensure commit is called