refactoring, trying to get mesh working