Format sections. Add in length squared. Make distance function more readable and remove multiple calls to same fns