Better layout class adaptation code