I understand what they do. But since you have a variable named lastOnscreen, the name of calcDeepestLastOnscreen() implies that it is modifyting only lastOnScreen, and I'd expect there to be a corresponding function calcDeepestFirstOnscreen().  So I think this function would be better named calcLastDeepestOnscreen.