Added critical section for context - based operations + Code refactoring for FrokAgent