fix stderr line endings; trim commented code; add consistent return statements