bug fixes for #50 and #47