Dph optimization

Optimized DPH code.
Oh no that's okay, I'll work on the typos too.