Some bug fixes found whilst getting the Pi Approximation demo working.