Patch pushed as 3fef3cb8d2d9600764f5447f66dd2b4576dd0a61 with some modifications. Thanks.