Script: Fix some bugs