leaves update and margin setting.