Final version of the PAT code