Fixed minor bugs + added logging.