Rework of divergence
Implementing bugfixes to cavity