Fix various crashes when 'null' is the ship given to a ship method
More fixes to pirate AI.