use a helper function to retrieve the CPluginDirectory instance from the handle, thanks to ulion
use a map instead of a vector for holding plugin handles - ensures that we don't attempt to access the wrong one if an earlier handle was removed. Thanks to ulion for finding the issue