Fix some bugs in make theory script