Tidied up a bit and reduced the logging.