Moved all scan state related code into the inner class of IMEAdapter class.
Handled scan state changes.