add to gitignore valgrind logs
fix bugs in hash, small code improvements
free all pointers allocated with malloc
small fixes and code rearrangement