Fixed optimized GenerateShip code bug