Fixed some bugs and made the agent parametric so we can run multiple instances of it