Fix some memory leaks
More appropriate console logging