Changed some bugs on agent