Fixed issue 3538 and issue 3589