removed dead code: the layout was set only locally.
[BUG #8601] made code more safe against potential memory-leaks