Implement initKeyMap and PA Setup

Also added some comments and function headers