Fixed serious (potentially) locking issues (or lack thereof).