issue #2 fixed and other improvements