Fix bug in swarm handling and add a lot of logging and testing