Fix #1653, #1686, #1685