Fixed flashStateChanged function.