Added pre-computation of curves plus memoisation
Packaged for npm