Moved all functions from util.js to services.