Fixing bugs 5477 and 5493

View commits detail for further information...