Reorder construction of the target list so that we do not insert an atom that isn't yet created. Also make sure that we order targets in order of preference.