Properly garbage collect when destroy is called. Refactor code a bit.