Removed some ugly memory leaks