Added debug and continuation of protection

The rough list of remaining things to implement is maximum gate size,
gate branching prohibition and protection for both implementations.
Unfortunately I've been very busy lately and the development almost came
to an halt. I'll try get this done before the weekend, perhaps before
1.4.6 RB.