Fix bug where generated code not deleted