Fixed some bugs in matter and chain creation.