This is the fix for the second issue mentioned in the description.