Minimize differences from the upstream of #13 .

Some adjustments for #13 before merging.