improvments for flash detection (#19)