Fixed bugs in KL estimation