Move some stuff around plus logging.