Support new layouts

Support new layouts and add some tests.