Distance matrix fix

This pull request fixes a number of issues in the distance matrix tool including:
   * incorrect field name in N*Kx3 format matrix
   * bug in NxT format matrix where attributes function is not called, just used without ()
   * bugs in NxT format matrix in field names and contents generated