Fixed some locking issues