Optimize and cleanup delta application logic