added suggested changes to get_endmost_triplet() refs #534
fixed minor issue