Fixed a different set of potential memory leaks paired with the previous ones.