Add locking to tilediff script