Bug fixes: #5697, #5690, #5687, #5685