flash detection & template improvements