New listDevices

I wanted to fix some bugs I've experienced with my cellphone on this branch. But the bug just vanished. It used to happen when a device tried to handshake twice. But now it doesn't.

I ended up just creating the listDevices() method on the gateway. Also did some cleanup.