fixed texture orientation and cleaned up resource management