Some class invariants cause thread scheduling problems, fixes #216