Fix variable visibility, add gradient variable.