Fixed some bugs with layout manager