Move the 'contains' logic into an association

Fixes #579