bug fixes for #15, #16 | merged pull request commit 753b004 (pull #17)