Optimisations, cardinality(), and minor edits.