Fix issue#370 and issue#388