Improved handling of saving intermediate solutions. Still not working.