Debug and cleanup. Merged t_logic and state_update into one process.