Continue work with fixing multitasking error conditions

This is mostly just stuff to fix the multitude of data corruption errors
caused by race conditions / insufficient locking.