Initial modifications to detect flash

Will not compile until further changes are made