Fix how layers work and enable full control

Some code reorganization was needed, but now complete layer manipulation
through the layerTreeView (with live update) is enabled. Some code was
also fixed.
Add some debug output to Microcosm

Some (but definitely not all) debug output was added to Microcosm,
mainly to test out the layer control feature.