fix #340

this patchset is intended to fix #340.