import caf changes from @chil360 and cleanup