Initial refactoring of the rendering process, memory overflow solved