Fixed some internal issues in hap