Fix remaining problems in #5396 and #5401