Patch pushed as c7422310ee0ae129911e59a9e08116e52b54c8ba with a few modifications. Thanks.