This reland 945aa520ef07a3edb655f3f38e4c3023658dd623 with fixes. This reverts commit 10bc3362a1a8a3df2660bf65db0ec1ccab646e1b.
This reland 945aa520ef07a3edb655f3f38e4c3023658dd623 with fixes. This reverts commit 10bc3362a1a8a3df2660bf65db0ec1ccab646e1b.