Minor fixes to shell and R scripts.