Some bug fixes, in proccess of changing how the folding works