Updated agent and main functionality