Fixed name handling to better handle NULL names and name='' cases.