Added program pattern state machine and a small test program