Moved the agent resolution and normalisation into the lib/agent.js file