Re-organised generic purpose functions to be library functions
Improved code for computation of point at length