The post above is my post. The session was just expired and I was recognized as "Anonymous Monk" :)
A little update: I have unmodified Version#2 running for several hours under heavy load (10-15 scripts at once) and there are still no file corruptions. But probably it's just a luck. My question about interference between flock() and rename() is still open...