cleanup mesh code