Move sluice to its own module. Implement reconnect on error. Minor formatting fixes