Now uses boost::shared_ptr to hold states.