Fix agent.cs and bunch of misc improvements.