Fixing bug in the recalculate_values() function.