Fixes to not pass around pointers to the first element of an empty vector.
Return failure on error.