Fix error logic

and clean error logs.