Updated Main scripts

Really revamped the PM script.  I need to run some tests but it should
be good to go soon.