moving monitoring into a thread, adding some logging.