Refactor texture so it uses destructors