major update with process handling and cleanup