Fix bugs in creating summary table
Optimize the SQL in residual computation
Redefine and rewrite zph