Fix layout crashes