Slightly polished up examples; added state machine