Fixed some (really big)  memory leaks