Move some code from Cop to Util