Skeleton finished.

Known issue:
  - The state machine is Thread-unsafe.