Rmoved bugs in logging procedure.