address most of Mathias code review suggestions, failing complex deadlock test