Fixing reference into empty vector run time exception. Replacing it with more predictable behavior.