AHC Successful Spanish attack on Algiers 1775

In 1775 the Spanish sent a large force to attack Algiers, under the command of Alexander O'Reilly, resulting in a disastrous defeat. The apparent causes were the Spanish landing in the wrong place, a complete lack of intelligence, and squabbling between the Army and Navy. (Everything I know I learned from Wiki)
http://en.wikipedia.org/wiki/Invasion_of_Algiers_(1775)

Any way to make the result more successful? What would the effects be on Spanish military reform, or further colonisation of North Africa? Would it affect their involvement with France in the American Revolution? I noticed that in 1774 the British backed Sultan Muhammed ben Abdullah in a (failed) attempt to drive the Spanish out of Melilla.
 
Top