Tidied up texture memory management.