Patch pushed as cfc2471159740d0a5560bbe598ff7b70a131ee19 with a few modifications. Thanks.