Fixed a bug in the layout manager