Restructured solenoid actuation code.