Openclose functionality for state buttons
Improved task state handling