Thanks @dewalt
The suggested changes are in the updated patch. Please review.