Fix #1001774: don't discard generated code

Also fix another instance of the same bug.
Merge pull request #456 from greenrd/fix-wizard-rebased-1001774

Fix #1001774: don't discard generated code