Further work on fixing Pam's mod compatiblity

Right now I think almost everything is to where it was before.
The code needs to be cleaned up and some minor refeactoring.
More work on compat, will not compile