Precalculate some sin and cos to reduce floating-point ops.
Fixed numerous tabs and typos
Fixed bug in pi2
Merging bug fix branch from guillochon, Fixed bug in pi2