Restructure a bit to accommodate different algorithms