Interaction of defects and metals with nanocavities in silicon