fixes for #557 based on code review