Custom elements fixes

Fixes crash on custom element with spawn special. Also fixes generator-based custom elements.