minor tweaks
fixed memory leaks and initialization errors - valgrind is happy!