Initial version without threads