memory leaks and unitialized variables caught by valgrind fixes (thanks goes to Eero Tamminen for bringing the issues to attention)