Build fixes, fixed segfault and logging.