Code cleanup and added main 'PAM' class