Fixed bugs in indexing. distance list is now better indexed when rows are missing. Distance matrix is now created correctly.