Implemented mesh optimization functionality