Metacore plugin integration

Adds metacore plugin integration functionality
I'm not a fan of nesting too much stuff either, but as long as code is functional and readable with minimal overhead, I'm OK with it. If I were to write this block, I'd do it differently, but I don't want to be too picky when it comes to others...
Having said that, the author of this code has rewritten it (plus implemented extra error checking), so I'll be submitting a new pull request shortly.