Removed dead code, and fixed memory leak.