Close file when done
Added missing NULL check
Fixed some small bugs found via static analysis
_add was missing the set to the backing size, so it would realloc way to much if adding multiple items