Added better support for flash detection