Pull #938 for v1.0.1

The changes from pull #938 with conflicts resolved for v1.0.1 branch.