Index: libs/ardour/audioengine.cc
===================================================================
--- libs/ardour/audioengine.cc	(Revision 3155)
+++ libs/ardour/audioengine.cc	(Arbeitskopie)
@@ -527,7 +527,7 @@
 		session = 0;
 	}
 	
-	remove_all_ports ();
+	//remove_all_ports ();
 }
 
 void
@@ -555,6 +555,7 @@
 {
 	Port* newport = 0;
 
+	cerr << "trying to register port with name " << portname << endl;
 	try {
 		if (dtype == DataType::AUDIO) {
 			newport = new AudioPort (portname, (input ? Port::IsInput : Port::IsOutput), publish, frames_per_cycle());
@@ -564,11 +565,17 @@
 			throw unknown_type();
 		}
 
+		cerr << "successfully got port " << portname << " with address " << newport << endl;
+
 		RCUWriter<Ports> writer (ports);
 		boost::shared_ptr<Ports> ps = writer.get_copy ();
+		cerr << "Address of ports list: " << ps << endl
+		     << "Ports set size before insert: " << ps->size() << endl;
 		ps->insert (ps->begin(), newport);
+		cerr << "Ports set size after insert: " << ps->size() << endl;
 		/* writer goes out of scope, forces update */
 
+
 		return newport;
 	}
 
@@ -608,22 +615,31 @@
 {
 	/* caller must hold process lock */
 
+	cerr << "about to unregister Port xx  x" << &port << "\n";
+
 	if (!_running) { 
 		/* probably happening when the engine has been halted by JACK,
 		   in which case, there is nothing we can do here.
 		   */
+		cerr << "not running\n";
 		return 0;
 	}
 
 	{
+		cerr << "before getcopy\n";
 		
 		RCUWriter<Ports> writer (ports);
 		boost::shared_ptr<Ports> ps = writer.get_copy ();
 		
+		cerr << "Ports set size: " << ps.get()->size() << endl;
+
 		for (Ports::iterator i = ps->begin(); i != ps->end(); ++i) {
+			cerr << "before delete" << endl;
 			if ((*i) == &port) {
+				cerr << "About to delete " << &port << endl;
 				delete *i;
 				ps->erase (i);
+				cerr << "After erasing ports size: " << ps->size();
 				break;
 			}
 		}
@@ -631,6 +647,7 @@
 		/* writer goes out of scope, forces update */
 	}
 		
+	cerr << "before remove_connections\n";
 	remove_connections_for (port);
 
 	return 0;
Index: libs/ardour/io.cc
===================================================================
--- libs/ardour/io.cc	(Revision 3155)
+++ libs/ardour/io.cc	(Arbeitskopie)
@@ -202,6 +202,7 @@
 
 IO::~IO ()
 {
+	cerr << "In destructor of IO" << endl;
 	Glib::Mutex::Lock guard (m_meter_signal_lock);
 	Glib::Mutex::Lock lm (io_lock);
 
