Fixed a bug where gadgets may clobber intermediate values.