hap2: several changes; see documentation for details