did some interesting debugging and minor fixes to the saving algo