Fix spaghetti in sumk_lda_tools