Initial commit of old code and recent example usage

Needs changing into a plugin.