Minimal switching tentatively working

No tests, not all edge cases covered, must specify an exact tag, don't handle dependencies, but a good start!