Clear out attached items when deleting collection

Fix #507.