ref-count trait objects to avoid double-free, probably will need to do this everywhere