massive update: split the mesh generating part to a new class