handles disconnects and saving
merged main