Take from pmaddox with a bit of cleanup. Fix refcnt on noit connections.