Issue #2204345 by tim.plunkett: Adjust PluginBag's instance handling methods.
Issue #1774104 by sun: Replace all trivial drupal_write_record() calls with db_merge().