Added logging & some fixes