Fix errors and bugs in untils.R.