Fix layout problems on minimize and maximize