Solved memory corruption/leaks