Fix strange behavior with layout