Added theme change detection and handling