Adding debug mode switch
Updating logging