Initial implementation of LPGate.m.  Still a few errors to fix.