Fix bug in chain creation