better handling of main visibility