Added validation handler and fixed logging.