Fix 1728 (Fixed up from #1729)

This is just @gazpachoking's PR #1729 in a mergable state and with the PR feedback that @Lukasa left on it.