Added NULL return on error docs in comments.
fixed pushed bug.