Fix for bugs #2368 and #2369