Import bugfix 61946b5624d23c49e5b8504af2b8052106f26224 from my etcaetera fork