Fix #2528 and #2510