Move util functions because Lua doesn't support circular requires.