Better handling of state and visibility