XBee S1 DigiMesh - Problem with remote AT Commands (Java API)

Hey there I hope I can find someone to help me fix and understand my problem.

So I am using 2x Xbee S1, both connected to USB via gateway dongle. On one module I am using the java api and the other one is open via xctu to verify incoming commands and changes. Both modules are running the latest DigiMesh firmware.

Now the thing is, sometimes it takes quite long to find the other device. Both devices share the same PAN and channel. In my Java Programm I have set the discovery timeout to 2 minutes and sometimes it still needs to search 3-4 times until it finds the other device.

But this is not the main problem. I have both devices set to API=1 now. Before they were set to API=2.

With API2: everytime I wanted to send a remote ATCommand, for example remoteDevice.setParameter(“SO”, new byte[]{0x02});
I got a NullpointerException OR an receive packet timeout exception. But the strange thing is when I get the receive packet timeout exception, the value is set correctly on the remote device but in the terminal I can not observe any incoming ATCommand.
With the Nullpointerexception nothing is working.

With API1: If I want to do remoteDevice.setParameter(“SO”, new byte[]{0x02}); I get whether a nullpointerexception or a “ATCommandException: There was a problem sending the AT command > TX Failure”.
But again with the ATCommandException the value is set and with the nullpointer not.

Can someone please tell me how to speed up the remote device discovery and get the remote ATCommands properly to run?

Any kind of help is greatly appreciated.