fixes for #6 and #7, real world testing needed