Fixes to better handle process restarting