Please find attached a patch fixing both the issues identified in this bug: