Fix bugs in layout