finished refactoring, though texture is broken