major changes to remove timeout. Construct stack of threads and states.