bug fixes for #50 and #47

bug fixes for #50  and #47