This Fixes #754,#755,#656,#828,#823 #877

We can abandon the PR#877 as that's out of synch with latest version of code. I will be closing that PR.
But wanted to keep the conversation so we can refer using the PR no #877.
You can review this.