Replace layermod with exit

Based on top of refactormovement branch.

Fixes #31.