Less logging on the stdout, minor changes.
Locking to avoid concurrent scripts; minor improvements.