Improve ST_EndPoint

@mlecoeuvre Please see these corrections.