Delete nested elements properly

Partly addresses #97