Fix for issues #7 and #3