Patch pushed as f0c8cdb56519371432ed8b62c8eff446d8c5be6f with a few modifications. Thanks.