mesh refactoring
fix memory