reworked locks, still include ne code about to be removed; wanted to save it in commit first
Preliminary commit before adding secondary locking