Move getDefs to a more generic getOrCreate utils function