Rearranged plugins.h functions
wip: Implemented finer grained plugin hooks

issue #445
Merge branch 'plugins' into without_threads