Initial rewrite of Connections and Couplings. Functions added to detect connections and couplings. Support for cavities has been added.