Fixed several memory leaks - some confirmed - some after chasing valgrind down the entire night