Few memory leaks were fixed.

First memory leak occurred due to improper linked list construction
in `add_to_ptr_list` function.
In case if list had tail - result of execution would be lost pointer of
previous tail.

Second memory leak was in `output_error`.
Function allocated `dataset` but never freed allocated memory.