Fix #374 and #379.