Well.. Most of the source in that snippet is already outdated On the plus side is that it works alot better. Decided to use dynamic arrays to store textures and changed a few lines to avoid dereferencing nil pointers when trying to access deleted textures.