Fix a 'this' error and add some better logging