Added logging in debug mode