quick hacked demo. Needs a break-up, rewrite and documentation