Refactors for clarity; calculate closest point during search.