Added logging functionality + made logging calls better