The Formalism and Implementation of PATR-II