Fix for bug that would crash trace function if peak were cut off in the end of the run