Fix #1677, needs polish