Event and layout bug fixes