Moves memory leak code to module