Partially revert 5566b7f7533eb0302da1b54b3d487d459424541c

Fixes #2512