Rewrote p_Lcm to fit for the no-shift version.