Dph optimization

Optimized DPH code.
"minimum" (I'll just fix this plus a couple of existing comment typos in this file - make sure you merge changes from trunk before doing further work here).