Big changes inlayout, minor bugs fix