I think I have the Bartlett decomposition working, also made an R script to test (not proper tests, but better than running all files when not needed yet. Haven't tested accuracy yet, but 0s and numbers are in the right place, and numbers make sense.