Fixed some bugs and wrote the mold.