Extend master-master capabilities and add SSL #189

This is #189 rebased on top of the latest master.