Memory leak fixes

New function close_db called atexit. Temporary fix in tag_file. Also
some smaller fixes. Done after some valgrinding.
Added -pedantic option to compilation