fix mesh creation in each loop, fix loop vars, fix index handling for getting vertices