Added template read/write plugin code, and modified all plugins
to use template code where applicable, for a clear comparison.