Removed debug statements. Corrected issues reported by valgrind.