fix issue #48, issue #66