Rewrote the GPIO jack detection code.