This trick can and probably should be used in many other places.
mentioned in commit 6bbf3e67
mentioned in commit bb24b979