Fix some bugs so the script now runs