added state machine demo for calibre plugin. few small debugging changes.