Fix bugs and add two new scripts