added log_lock and fixed a few minor things