wip, fixes large memory leak and exposes another small one in the same theme