Some cleanup and changed demo to use new LocalGateway abstraction
(untested)