update indexing code to be faster, add robust fitting image, begin work on diag