Needs javadoc, especially re use of the allTypes set.