Commit of the rest of Gunnars file locking patch.