Fixed for issue 6158 and 6161