Properly set an exception when NULs are found in a string. Also: cleanups.