Fix bugs in new defn discovery