improve debug print at generate script
impprve error handling