Fixed Memory Leaks by Granty.