Refactor of model rendering and animation code