Fix apply leaf mask