Implemented better texture memory management.