Some cleanup to Texture, fixed several memory leaks.