Fix element generator for situations where only available_contents are present. Refs #407
Re-attach folding events on restored elements. Closes #411