Tweaked solenoid code.