Prevent changing frames while changing layout, and viceversa