Changes to logging and couple bug fixe.