Remove dead code.
Some tests and re-work of the implementation.

Layer made state-less, just as PathLayer.