Fixed the "hurt agent" so that it does not crash, but it stilld does not work.
Still stuck with the removeAgents function that still does not work.