Rete performance optimization: use std::shared_ptr only where necessary;