Fix #4506 in a pretty hacky way.