Add locking, to avoid running the same simulation twice and overwriting files