Fixing segfault on layout change