fixed more bugs from the PAI