More refactoring. Added LocalGateway to test network, but untested at the
moment.