copied add_path functions into main; fixed a memory leak and remove_comment()