Implemented a basic state machine to get started.