Issue #581 and #579 fixed