Improved #2744 after another review.

Thanks apollo13 for the review.