Modified Main and ThreadSlave for new architecture.