Improve media state management