fix plotphi range
use trigonometric optimizations
Merge branch 'master' into mac