Add locking and move the actual sims to proper source file.