Optimisation
 - excessive calls to sql SELECT in genexchange and gxsnet, naive algo