Fixes to issue #6 and #7

These changes are my proposal to fix issue #6 and #7