issue #365: adding some improvements.