Merge bugfixes to master

@Raizlabs/maintainers-ios Anybody currently using data manager mind taking a quick look here? @joe-goullaud fixed a few bugs, we should merge these into master if it looks good.
@joe-goullaud After I made the comment about this, I remembered that `free` (surprisingly) actually is safe to call with NULL.