Added locking to py.py. Simultaneous write causing loss of stored data.