Layout related bug fixes