Tweaked pi code.