Check for nil pointer in Beginx, Preparex.

Found another couple of cases where nil pointer is dereferenced on error.