Hacking in a fix for this memory leak, I swear I will go back and make the code pretty at some time :D.