fix issue #7 and a legacy bug