restore function and fix for 'this' in logging functions