Wrap generated code in a block if necessary (closes #160)