Fix some issues with rwlock corruption that caused deadlock like symptoms.