Fix #983, #1002