Reduce scope of util functions. Remove unused code.