Minor cleanup, error checking fixes.