Fix some type conversion issues in the script