Fix #1112 & #1139