Fix bugs in caps plugin

FIx some bugs in caps plugin:
1. don't compare datasets, use flags instead;
2. use full node as key.