added 'learn' endpoint and debug logging